package com.xugongzhang.ext;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * @author X
 * @date 2022/12/11 23:01
 */
//@Component
@Slf4j
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        log.info("MyBeanFactoryPostProcessor.postProcessBeanFactory   invoke...");
        log.info("BeanFactory中现在共有 {} 个Bean", configurableListableBeanFactory.getBeanDefinitionCount());
        String[] names = configurableListableBeanFactory.getBeanDefinitionNames();
        log.info(JSON.toJSONString(names));
    }
}
